package com.hubu.core;

import java.util.Map;

public class PutHandler extends Handler{
    /**
     *
     *
     * 每一个handler关联一个database
     * @param database
     * @return
     */
    @Override
    protected Result handle(Database database, String commandType, Map.Entry<String,String> entry) {
        if(commandType==null||!commandType.equals("put")){
            throw new RuntimeException("error commandType");
            //处理器
        }
        Result result=new Result();
        String oldValue = database.put(entry.getKey(),entry.getValue());
        if(oldValue!=null){

            result.setObject(result);
            result.setObject("string");
        }
        return result;
    }
}
